﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Drawing;
using System.Web.SessionState;
using Maticsoft.Common;
using System.Text;

namespace Admin.Search
{
    public partial class CheckFormSearch : System.Web.UI.Page
    {
        protected System.Web.UI.HtmlControls.HtmlInputButton btnCancel;
        public string adminname = "管理部门";
        ChinaSoft.BLL.BLL_tb_MidSoft_CheckupForm bllCheckupForm = new ChinaSoft.BLL.BLL_tb_MidSoft_CheckupForm();
        ChinaSoft.Model.Model_tb_MidSoft_CheckupForm modelCheckupForm = new ChinaSoft.Model.Model_tb_MidSoft_CheckupForm();

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                //imgBtnDel.Attributes.Add("onclick", "return confirm(\"你确认要删除吗？\")");
                BindData();
            }
        }

        #region gridView
        public void BindData()
        {
            #region
            //if (!Context.User.Identity.IsAuthenticated)
            //{
            //    return;
            //}
            //AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
            //if (user.HasPermissionID(PermId_Modify))
            //{
            //    gridView.Columns[6].Visible = true;
            //}
            //if (user.HasPermissionID(PermId_Delete))
            //{
            //    gridView.Columns[7].Visible = true;
            //}
            #endregion
            StringBuilder strWhere = new StringBuilder();
            if (Request.Params["ProjectId"] != null && Request.Params["ProjectId"].Trim() != "")
            {
                strWhere.AppendFormat(" and ProjectInfoId={0}", ChinaSoft.Common.Input.SetInt(Request.Params["ProjectId"]));
            }
            if (Request.Params["CheckType"] != null && Request.Params["CheckType"].Trim() != "")
            {
                strWhere.AppendFormat(" and CheckupType='{0}'", Request.Params["CheckType"]);
            }
            if (txtCheckupFormNumber.Text.Trim() != "")
            {
                strWhere.AppendFormat(" and CheckupNumber like '%{0}%'", txtCheckupFormNumber.Text.Trim());
            }
            if (ddlSearchType.SelectedIndex > 0)
            {
                strWhere.AppendFormat(" and CheckupType='{0}'", (ddlSearchType.SelectedIndex - 1));
            }
            try
            {
                ChinaSoft.BLL.Common.Pager.BindGridView(gridView, AspNetPager1, "V_CheckupFormList", "CheckupFormId", "*", strWhere.ToString(), "CreateTime desc", "");
            }
            catch (Exception ex)
            {
                Response.Write("数据库错误：" + ex.Message);
                Response.End();
            }
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
        protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gridView.PageIndex = e.NewPageIndex;
            BindData();
        }
        protected void gridView_OnRowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Text = "<input type=\"checkbox\" id=\"cbSelectAll\" name=\"cbSelectAll\" onclick=\"javascript:checkJs(this.checked);\" />";
            }
        }
        #endregion

        protected void btnSearch_Click(object sender, ImageClickEventArgs e)
        {
            BindData();
        }
    }
}